package org.example.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.example.model.Sysrole;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class SysroleAdvice {

    @Pointcut("execution(* org.example.Service.SysroleService.*(..))")
    private void sysroleptx(){}

    @Around("sysroleptx()")
    public Object runrole(ProceedingJoinPoint pjt) throws Throwable{
        //获取签名对象
        Signature signature = pjt.getSignature();
        long start = System.currentTimeMillis();
        Object ret = null;
        for (int i = 0; i < 10000; i++) {
           ret = pjt.proceed();
        }
        long end = System.currentTimeMillis();
        System.out.println("万次执行"+signature.getDeclaringTypeName()+"-->"+
                signature.getName() +"："+(end-start) + "ms");
        return ret;
    }

}
